package workspace;

import java.util.Scanner;

public class test31 {
    public static void main(String[] args) {
        int[] value= {1000,500,100,50,10,5,1};
        String[] str = {"M","D","C","L","X","V","I"};


        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        StringBuilder res = new StringBuilder();

        for (int i = 0; i < value.length; i++) {
            while(value[i] <= num){
                res.append(str[i]);
                num -= value[i];
            }
        }
        System.out.println(res.toString());
    }
}
